package cn.toleo.item.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.toleo.item.pojo.Item;
import cn.toleo.pojo.TbItem;
import cn.toleo.pojo.TbItemDesc;
import cn.toleo.service.ItemService;

/**
 * 商品页面展示controller
 * @author Administrator
 *
 */
@Controller
public class ItemController {
	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/item/{itemId}")
	public String  showItem(@PathVariable Long itemId, Model model){
		//主干基础
		TbItem tbItem = itemService.getItemById(itemId);
		Item item = new Item(tbItem);
		TbItemDesc tbItemDesc = itemService.geTbItemDescById(itemId);
		//主干
		model.addAttribute("item", item);
		model.addAttribute("itemDesc", tbItemDesc);
		
		//结果
		return "item"; 
	}
}
